package com.cuxiaoyi.model;

import java.text.NumberFormat;
import java.util.Date;

public class Item extends com.taobao.api.domain.Item{
	
	private static final NumberFormat f = NumberFormat.getNumberInstance();
	static
	{
		f.setMaximumFractionDigits(2);
	}
	
	public static final short STATUS_NOT_PROMOTED = 0;
	public static final short STATUS_NOT_STARTED = 1;
	public static final short STATUS_PROMOTING = 2;
	public static final short STATUS_OUT_OF_DATE = 3;
	
	private long promotionId = -1;
	private String discountType;
	private String discountValue;
	private Date startDate;
	private Date endDate;
	private String promotionTitle;
	private String promotionDescription;
	private short status;
	
	public void setPromotionId(long promotionId)
	{
		this.promotionId = promotionId;
	}
	
	public long getPromotionId()
	{
		return promotionId;
	}
	
	public boolean isPromoted()
	{
		return promotionId > 0;
	}

	public String getPromotionPrice() {
		double p = Double.parseDouble(getPrice());
		if ("PRICE".equals(discountType))
		{
			p = p - Double.parseDouble(getDiscountValue());
		}
		else
		{
			p = p * (Float.parseFloat(getDiscountValue()) / 10);
		}
		
		return f.format(p);
	}

	public void setDiscountType(String discountType) {
		this.discountType = discountType;
	}

	public String getDiscountType() {
		return discountType;
	}

	public void setDiscountValue(String discountValue) {
		this.discountValue = discountValue;
	}

	public String getDiscountValue() {
		return discountValue;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setPromotionTitle(String promotionTitle) {
		this.promotionTitle = promotionTitle;
	}

	public String getPromotionTitle() {
		return promotionTitle;
	}

	public void setPromotionDescription(String promotionDescription) {
		this.promotionDescription = promotionDescription;
	}

	public String getPromotionDescription() {
		return promotionDescription;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	public short getStatus() {
		return status;
	}

}
